package cn.iocoder.yudao.module.shop.controller.admin.giftcard.vo;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import javax.validation.constraints.AssertTrue;
import javax.validation.constraints.NotNull;
import java.util.Objects;

@Data
public class ShopGiftCardBindReqVO {
    @Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "10586")
    private Long id;

    @Schema(description = "礼品卡编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10586")
    private String cardId;

    @Schema(description = "手机号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10586")
    @NotNull(message = "绑定手机号不能为空")
    private String mobile;

    @Schema(description = "二维码", requiredMode = Schema.RequiredMode.REQUIRED, example = "10586")
    private String code;

    @Schema(description = "卡密", requiredMode = Schema.RequiredMode.REQUIRED, example = "10586")
    @NotNull(message = "卡密不能为空")
    private String cardPwd;

    @AssertTrue(message = "id与卡片编号不能同时为空")
    public boolean isValidIdAndCardId() {
        return Objects.nonNull(id) || Objects.nonNull(cardId);
    }
}
